package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.OrganizationDepartment;
import com.xmy.cultivate.service.IOrganizationDepartmentService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 组织部门 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2025-04-28
 */
@RestController
@RequestMapping("/api/admin/organizationDepartment")
public class OrganizationDepartmentController extends BaseController{

    @Autowired
    IOrganizationDepartmentService iOrganizationDepartmentService;


    /**
     * 获取校区名称
     * @return
     */
    @GetMapping("/getSchool")
    public Result getSchool() {

        List<OrganizationDepartment> organizationDepartmentSchoolList = iOrganizationDepartmentService.getSchool();

        return new Result(Code.OK, organizationDepartmentSchoolList, Code.GET_OK_MSG);
    }
    /**
     * 获取部门名称
     * @return
     */
    @GetMapping("/getDepartment")
    public Result getDepartment() {
        QueryWrapper<OrganizationDepartment> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("department_id","department_name");
        queryWrapper.eq("status",1);
        queryWrapper.groupBy("department_id");
        List<OrganizationDepartment> organizationDepartmentList = iOrganizationDepartmentService.list(queryWrapper);
        return new Result(Code.OK, organizationDepartmentList, Code.GET_OK_MSG);
    }

}
